﻿<%@ Page Title="Galery" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Galery.aspx.cs" Inherits="IP_PROJECT.Galery" %>
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
    <hgroup class="title">
        <h1><%: Title %>.</h1>
    </hgroup>
    <asp:LoginView id="AdminView" runat="server">
         <RoleGroups>
            <asp:RoleGroup Roles="Admin">
                <ContentTemplate>
                    <table>
                    <tr>
                        <td>Name:</td>
                        <td><asp:TextBox ID="ImageName" runat="server" MaxLength="50" /></td>
                    </tr>
                    <tr>
                        <td>Description:</td>
                        <td><asp:TextBox ID="ImageDescription" runat="server" MaxLength="500" /></td>
                    </tr>
                    </table>
                    <p>
                        <asp:FileUpload id="FileUploadControl" runat="server" />
                        <asp:Button runat="server" id="UploadButton" text="Upload" OnClick="UploadButton_Click" />
                    </p>
                </ContentTemplate>
            </asp:RoleGroup>
         </RoleGroups>
    </asp:LoginView>
    <asp:Repeater ID="Repeater1" runat="server" DataSourceID="ImagesDateSource">
        <ItemTemplate>
            <%# Eval("Name") %>
            <asp:LoginView id="AdminView" runat="server">
                 <RoleGroups>
                    <asp:RoleGroup Roles="Admin">
                        <ContentTemplate>
                            <asp:Button ID="Delete" runat="server" Text="x" OnClick="Delete_Click" CommandArgument='<%# Eval("Id") %>' />
                        </ContentTemplate>
                    </asp:RoleGroup>
                </RoleGroups>
             </asp:LoginView>
            <br />
            <img alt="" src="Image.aspx?Id=<%# Eval("Id") %>" />
            Description: <%# Eval("Description") %><br />
        </ItemTemplate>
    </asp:Repeater>

    <asp:SqlDataSource runat="server" ID="ImagesDateSource" ConnectionString='<%$ ConnectionStrings:DefaultConnection %>' SelectCommand="SELECT [Id], [Name], [Description] FROM [Images] ORDER BY [Id] DESC"></asp:SqlDataSource>
</asp:Content>
